<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('表字段批量选择')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>表名称：</label>
                            <select name="tableId" id="tableId" class="form-control m-b selectpicker" data-live-search="true">
                                <option th:each="dict : ${tableInfoList}" th:text="${dict.tableName}" th:value="${dict.id}"></option>
                            </select>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('table:table:edit')}]];
    var removeFlag = [[${@permission.hasPermi('table:table:remove')}]];
    var prefix = ctx + "table/table";
    var tableInfoList = [[${tableInfoList}]];
    $(function() {
        var options = {
            url: prefix + "/fieldList",
            pagination: false,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'fieldName',
                    align: 'center',
                    title: '字段名称',
                    width: 200
                },
                {
                    field: 'fieldEnName',
                    align: 'center',
                    title: '字段英文名称',
                    width: 200
                }]
        };
        $.table.init(options);

        $("#tableId").on('select2:select', function (e) {
            $.table.search();
        });
    });

    function submitHandler() {
        var rows = $("#bootstrap-table").bootstrapTable('getSelections');
        if (rows && rows.length > 0) {
            var ids = [];
            for (var i=0; i<rows.length; i++) {
                ids.push(rows[i].id);
            }
            return ids.join(",");
        }
        $.modal.alertWarning("请选择字段");
        return '';
    }
</script>
</body>
</html>